package com.study.demo.aop.demo2;

import com.study.demo.aop.demo2.operationsource.ElvinOperationSource;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;
import org.springframework.lang.Nullable;

/**
 * @author: elvin
 * @time: 2019-05-23 14:33
 * @desc:
 **/
public class BeanFactoryElvinOperationSourceAdvisor extends AbstractBeanFactoryPointcutAdvisor {
    @Nullable
    private ElvinOperationSource elvinOperationSource;

    private final ElvinOperationSourcePointcut pointcut = new ElvinOperationSourcePointcut() {
        @Override
        @Nullable
        protected ElvinOperationSource getElvinOperationSource() {
            return elvinOperationSource;
        }
    };


    /**
     * Set the cache operation attribute source which is used to find cache
     * attributes. This should usually be identical to the source reference
     * set on the cache interceptor itself.
     */
    public void setElvinOperationSource(ElvinOperationSource elvinOperationSource) {
        this.elvinOperationSource = elvinOperationSource;
    }

    /**
     * Set the {@link ClassFilter} to use for this pointcut.
     * Default is {@link ClassFilter#TRUE}.
     */
    public void setClassFilter(ClassFilter classFilter) {
        this.pointcut.setClassFilter(classFilter);
    }

    @Override
    public Pointcut getPointcut() {
        return this.pointcut;
    }
}
